﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NiuX.Domain.Entities
{
    /// <summary>
    /// EntityBase
    /// </summary>
    public abstract class EntityBase
    {
        public abstract object[] GetKeys();
    }

    /// <summary>
    /// EntityBase
    /// </summary>
    /// <typeparam name="TKey">The type of the key.</typeparam>
    public abstract class EntityBase<TKey> : EntityBase, IEntity<TKey>
    {
        /// <summary>
        /// Gets or sets the identifier.
        /// </summary>
        /// <value>
        /// The identifier.
        /// </value>
        [AllowNull]
        [Key]
        public TKey Id { get; set; }

        public override object[] GetKeys()
        {
            return new object[] { Id! };
        }
    }

    /// <summary>
    /// IEntity
    /// </summary>
    public interface IEntity<TKey>
    {
        /// <summary>
        /// Gets or sets the identifier.
        /// </summary>
        /// <value>
        /// The identifier.
        /// </value>
        TKey Id { get; set; }
    }
}
